using UnityEngine;
using System.Collections;

public class RockBehaviour : DrawableGameObject 
{
	public Texture2D[] rockAnimation;
	bool roll = false;
	
	public override void Start () 
	{
		base.SetAnimations(null, rockAnimation, null, null, null);
		base.Start();
	}

	public void Update () 
	{
		if(roll)
		{
			transform.Translate(10 * Time.deltaTime, 0, 0);
			RunAnimation();
		}
	}
	
	public void RunAnimation()
	{
		base.RunAnimation("Run", "Loop");
	}
	
	void OnCollisionEnter(Collision other)
    {
		if (other.gameObject.tag == "Player")
        {
            other.gameObject.GetComponent<HP>().Damage(1);
            Destroy(gameObject);
        }
		
		if (other.gameObject.tag == "Floor")
        {
			roll = true;
		}
	}
}
